<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑配置</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="css/css.css"/>
</head>
<body>
<div class="editproperty">
    <form class="login layui-form" lay-filter="editForm" style="margin-top: 10px">
        <div class="layui-form-item">
            <i class="layui-icon layui-icon-username"></i>
            <input name="path" placeholder='路径' maxlength="16" readonly lay-verify='required'
                   class="layui-input"/>
        </div>
        <div class="layui-form-item">
            <i class="layui-icon layui-icon-username"></i>
            <input name="data" placeholder='数据' maxlength="16" required lay-verify='required|data'
                   class="layui-input"/>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="save">保存</button>
        </div>
    </form>
</div>
</body>
<script src="layui/layui.js"></script>
<script src="js/common.js" charset="utf-8"></script>
<script>
    function formRender(rowData) {
        layui.use(['form', 'jquery'], function () {
            var form = layui.form
              , $ = layui.jquery;

            form.val("editForm", {
                "path": rowData.path
                ,"data": rowData.data
            })
        })
    }
    layui.use(['table', 'layer', 'jquery', 'form'], function () {
        var layer = layui.layer,
                form = layui.form,
                $ = layui.jquery;

        form.on('submit(save)', function (data) {

            var field = data.field;

            field.editUser=layui.data('userData').data.loginName;

            //发送添加请求
            doAjax($, layer, 'POST', false, field, '/property/update', afterEdit);

            //保存成功回调函数
            function afterEdit(result) {
                if (result.status == "200") {
                    //保存成功的提示与跳转
                    layer.msg('编辑成功', {
                        icon: 1
                        , time: 1500
                    }, function () {
                        //iframe页面关闭自身
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        //刷新父级数据列表
                        window.parent.location.reload();
                    });

                } else {
                    layer.msg(result.msg);
                }

            }

            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });


    })
</script>
</html>
